#ifndef	_BTLFILE_DATATYPE_H
#define	_BTLFILE_DATATYPE_H

// btl self-define version 1.0 define
#define BTLFILE_VERSION10			0x10

// btl self-define index version 1.0 define
#define BTLFILEINDEX_VERSION10		0x10

// btl self-define file flag
#define	BTLFILE_MAGICNUMBER		0x42544C46

// audio type
#define	BTLAUDIOTYPE_MP3	0x1
#define	BTLAUDIOTYPE_G722	0x2
#define BTLAUDIOTYPE_ADPCM	0x3
#define BTLAUDIOTYPE_PCM	0x4

// audio attribute
typedef struct AudioAttr
{
	unsigned long audioType;
	unsigned long audioChannelNum; 
	unsigned long samplesPerSec; 
	unsigned long avgBytesPerSec; 
	unsigned long blockAlign; 
	unsigned long bitsPerSample; 
	unsigned long cbSize;
	unsigned char reserved[4];
}BtlAudioAttr;

// video attibute
typedef struct VideoAttr
{
	unsigned long width;
	unsigned long height;
	unsigned char reserved[8];
}BtlVideoAttr;

// video type
#define BTLVIDEOTYPE_UNKNOWN	0x00
#define BTLVIDEOTYPE_H264		0x01
#define BTLVIDEOTYPE_MPEG4		0x02

typedef struct VideoAttr2
{
	unsigned long width;
	unsigned long height;
	unsigned char videoType;
	unsigned char reserved[7];
}BtlVideoAttr2;

// btl self-define file date and time
typedef struct BtlFileDate
{
	unsigned short year;
	unsigned short month;
	unsigned short day;
	unsigned short week;
	unsigned short hour;
	unsigned short minute;
	unsigned short second;
	unsigned char pad[2];
}BtlFileDate;

typedef struct BtlFileDate2
{
	unsigned short year;
	unsigned short month;
	unsigned short day;
	unsigned short week;
	unsigned short hour;
	unsigned short minute;
	unsigned short second;
	unsigned short milliseconds;
}BtlFileDate2;

// btl self-define file head object
typedef struct BtlFileHeaderObj
{
	unsigned long btlFileMagicNum;		// indicate whether it is BTL file. 
									// It's value is BTLFILE_MAGICNUMBER
	unsigned long version;				// file version, current version is 1.0
	unsigned long totalFileLen;			// file total length, bytes
	unsigned long totalPlayTime;		// file total play time, ms

	BtlFileDate createDate;			// file created date	size = 16bytes

	BtlAudioAttr audioAttribute;		// audio attribute	size = 32bytes
	
	BtlVideoAttr videoAttribute;		// video attribute	size = 16bytes

	unsigned long dataObjPosi;			// data object locate
	unsigned long indexObjPosi;		// index object locate
	
	unsigned long startTimeTick;		// the time tick of first frame, ms
	unsigned long endTimeTick;		// the time tick of last frame, ms

	unsigned char reserved[32];
}BtlFileHeaderObj;

typedef struct BtlFileHeaderObj2
{
	unsigned long btlFileMagicNum;		// indicate whether it is BTL file. 
	// It's value is BTLFILE_MAGICNUMBER
	unsigned long version;				// file version, current version is 1.0
	unsigned long totalFileLen;			// file total length, bytes
	unsigned long totalPlayTime;		// file total play time, ms

	BtlFileDate2 createDate;			// file created date	size = 16bytes

	BtlAudioAttr audioAttribute;		// audio attribute	size = 32bytes

	BtlVideoAttr2 videoAttribute;		// video attribute	size = 16bytes

	unsigned long dataObjPosi;			// data object locate
	unsigned long indexObjPosi;		// index object locate

	unsigned long startTimeTick;		// the time tick of first frame, ms
	unsigned long endTimeTick;		// the time tick of last frame, ms

	unsigned long totalFrames;		
	unsigned char reserved[28];

}BtlFileHeaderObj2;

// btl self-define file index info of index object
typedef struct BtlFileIndexInfo
{
	unsigned long version;
	unsigned long totalIndexNum;
	unsigned char reserved[8];
} BtlFileIndexInfo;

// btl set-define file index entry of index object
typedef struct BtlFileIndexEntry
{
	unsigned long position;
	unsigned long timeTick;
} BtlFileIndexEntry;

typedef struct BtlFrameHeader {
	unsigned long reserved;
	unsigned long videoLen;
	unsigned long timeTick;
	unsigned short audioLen;
	unsigned char bIFrame;
	unsigned char bVol;
} BtlFrameHeader;

#endif	// _BTLFILE_DATATYPE_H

